package de.uniwue.cs.ir.vsr;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.SortedSet;
import java.util.TreeSet;

public class TokenInfoImpl implements ITokenInfo {

	private Collection<ITokenOccurrence> tokenOcc;
	private double idf;
	
	public TokenInfoImpl() {
		idf = 0;
		tokenOcc = new ArrayList<ITokenOccurrence>();
	}
	
	@Override
	public Iterator<ITokenOccurrence> iterator() {
		return tokenOcc.iterator();
	}

	@Override
	public void addPosting(ITokenOccurrence posting) {
		tokenOcc.add(posting);
	}

	@Override
	public void setIdf(double idf) {
		this.idf = idf;
	}

	@Override
	public double getIdf() {
		return idf;
	}

	// a SortedSet egy interface, a TreeSet pl egy implementacioja;
	// a sima SortedSet-re hibat adott ki (nem tudta castelni)
	// ez igy most nem dob cast hibat, de hogy jol rendezi-e, azt nem neztem meg
	@Override
	public SortedSet<ITokenOccurrence> get_postings() {
		// return (SortedSet<ITokenOccurrence>) tokenOcc;
		return new TreeSet<ITokenOccurrence>(tokenOcc);
	}

	@Override
	public Collection<ITokenOccurrence> getTok() {
		return tokenOcc;
/*		TreeSet<ITokenOccurrence> treeSet = new TreeSet<ITokenOccurrence>(tokenOcc);
		System.out.println("nr " + treeSet.size());
		return treeSet;*/
	}

}
